%Recibe R1
function [R,C,Sens]=celdas_rchbp(Wp,Qp,G,Wz,seteados)
    R=ones(3,1);
    C=ones(2,1);
    
    R(1)=seteados;
    
    b = 0.05;
    gamma = b/(1-b);
    beta = 2*(1-b)/(1/G+1);
    C(1) = 1/(Wp*R(1))*sqrt((1+gamma)/(gamma*beta));
    C(2) = C(1);
    R(2) = beta*R(1);
    R(3) = gamma*R(1);
    
    Sens = [SenRauchW(G,Qp,Wp,R,b,C);SenRauchQ(G,Qp,Wp,R,b,C);SenRauchG(G,Qp,Wp,R,b,C);zeros(1,5)];
    Sens = Sens';
end

function [senW]= SenRauchW(G,Q,W0,R,b,C)
    senW(1) = -0.5*(R(3)/(R(1)+R(3)));
    senW(2) = -0.5;
    senW(3) = -0.5*(R(1)/(R(1)+R(3)));
    senW(4) = -0.5;
    senW(5) = -0.5;
end

function [senG]= SenRauchG(G,Q,W0,R,b,C)
    senG(1) = (1+C(1)/C(2))*R(1)/R(2)*(1-b)*G;
    senG(2) = -(1+C(1)/C(2))*R(1)/R(2)*(1-b)*G;
    senG(3) = -R(1)/R(3)*b*G;
    senG(4) = -C(1)/C(2)*R(1)/R(2)*(1-b)*G;
    senG(5) = C(1)/C(2)*R(1)/R(2)*(1-b)*G;    
end

function [senQ]= SenRauchQ(G,Q,W0,R,b,C)
    senQ(1) = (1/2-(C(1)+C(2))*R(1)*R(3)/(R(1)+R(3))*Q*W0)*R(3)/(R(1)+R(3));
    senQ(2) = 1/2-b/(b-1)*C(2)*Q*W0;
    senQ(3) = (1/2-(C(1)+C(2))*R(1)*R(3)/(R(1)+R(3))*Q*W0)*R(1)/(R(1)+R(3));
    senQ(4) = 1/2-R(1)*R(3)/(R(1)+R(3))*Q*W0*C(1);
    senQ(5) = 1/2-(R(1)*R(3)/(R(1)+R(3))-b/(b-1)*R(2))*C(2)*Q*W0;
end